import React from 'react';
import { connect } from 'umi';
import { checkAuthCode } from '@/utils/utils';

const PureAuthComponent = props => {
    const { code, children, authData } = props;
    const authResult = checkAuthCode(code, authData);
    if (code && !authResult) console.log('无权限组件 ——', code);
    return <React.Fragment>{authResult && children}</React.Fragment>;
};

export default connect(({ menu }) => ({
    authData: menu.authData
}))(PureAuthComponent);
